package org.inasnet;

import java.awt.Font;
import java.util.*;

public class FontManager 
{
	public static Font getFont( String name, int size )
	{
		return getFont( name, 0, size );
	}
	
	public static Font getFont( String name, int style, int size )
	{
		Iterator< Font > fontIter = mFonts.iterator();
		
		Font font = null;
		
		if( fontIter.hasNext() )
		{
			font = fontIter.next();
			
			while( true )
			{
				if( font.getFontName().equals( name ) 
				 && font.getSize() == size 
				 && font.getStyle() == style )
				{
					return font;
				}
				
				if( ! fontIter.hasNext() )
					break;
				
				font = fontIter.next(); 
			}
		}
		
		font = new Font( name, style, size );
		
		mFonts.addLast( font );
		
		return font;
	}
		
	static LinkedList< Font > mFonts = new LinkedList< Font >();
}
